#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef double db;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+ch-'0'; ch=getchar(); }
	return x*f;
}
const db eps=1e-4;
int n,m,head[110],cnt,a[60],b[60],sum;
bool mp[60][60];
struct edge
{
	int v,next;
	db val;
}e[60*60*2];
void addedge(int x,int y,db z)
{
	e[cnt]=(edge){y,head[x],z};
	head[x]=cnt++;
	swap(x,y);
	e[cnt]=(edge){y,head[x],0};
	head[x]=cnt++;
	return;
}
inline bool equal(db a,db b)
{
	return abs(a-b)<=eps;
}
struct MF
{
	int idx[110],cur[110],S,T;
	void bfs()
	{
		memset(idx,0,sizeof(idx));
		queue<int>q;
		q.push(S);
		idx[S]=1;
		while(!q.empty())
		{
			int u=q.front();q.pop();
			for(int i=head[u];~i;i=e[i].next)
			{
				int v=e[i].v;
				if(equal(e[i].val,0)||idx[v])continue;
				idx[v]=idx[u]+1;
				q.push(v);
			}
		}
		return;
	}
	db dfs(int u,db _min)
	{
		if(u==T)return _min;
		db ret=0,k;
		for(int i=cur[u];~i;i=e[i].next)
		{
			int v=e[i].v;
			cur[u]=i;
			if(equal(e[i].val,0)||idx[v]!=idx[u]+1)continue;
			k=dfs(v,min(_min-ret,e[i].val));
			e[i].val-=k;
			e[i^1].val+=k;
			ret+=k;
			if(equal(ret,_min))break;
		}
		return ret;
	}
	db dinic()
	{
		db ret=0;
		while(true)
		{
			bfs();
			if(!idx[T])break;
			memcpy(cur,head,sizeof(head));
			ret+=dfs(S,INF);
		}
		return ret;
	}
}T1;
bool chk(db x)
{
	memset(head,-1,sizeof(head));cnt=0;
	for(int i=1;i<=n;++i)addedge(T1.S,i,a[i]);
	for(int i=1;i<=m;++i)addedge(i+n,T1.T,x*b[i]);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			if(mp[i][j])addedge(i,j+n,INF);
	return equal(T1.dinic(),sum);
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	n=read();m=read();
	T1.S=0;T1.T=n+m+1;
	int t=INF;
	for(int i=1;i<=n;++i)a[i]=read(),sum+=a[i];
	for(int i=1;i<=m;++i)b[i]=read(),t=min(t,b[i]);
	for(int i=1;i<=m;++i)
		for(int j=1;j<=n;++j)
			mp[j][i]=read();
	db l=0,r=(db)sum/t;
	while(!equal(l,r))
	{
		db mid=(l+r)/2;
		if(chk(mid))r=mid;
		else l=mid;
	}
	printf("%lf\n",l);
	return 0;
}
